<?php
if (!defined('IN_IPB')) exit("<h1>Incorrect access</h1> You may not access this file without the acp.");

class template_plugin
{
	var $ipsclass;
	
	// Plugin Pre-defined
	var $name = "";
	var $multiple = 0;
	var $cache_array = array();
	
	// Plugin Self-defined
	var $base_url;
	var $plugin;
	
	// Admin
	var $dir;
	
	// Public
	var $output = "";
	
	function acp_menu()
	{
		// Like $PAGES in admin_pages.php
		// No need for &act=army&code=module
		// $menu[$page_id][0] = Page name
		// $menu[$page_id][1] = Url
		// $menu[$page_id][2] = Look for folder before showing
		// $menu[$page_id][3] = URL type: 1 = Board URL 0 = ACP ARMY URL 2 = ACP URL
		// $menu[$page_id][4] = Item icon: 1= redirect 0 = Normal
		// $page_id is reserved from 0 to 9
		// Ten Page id is enough
		// Please start with zero
/*		return array(
					  1 => array('test',''),
					  2 => array('test2','do=test2'),
					);
*/	}

	function acp() { return; }
	function acp_install(&$input) { return; }
	function acp_settings()	{ return ""; }
	function acp_save_settings(&$input) { return; }

	function acp_uninstall() { return; }
	
	function _acp_start_form($a = array(),$n = "theAdminForm",$js="")
	{
		$form = array(  array( 'section'   , 'components'         ),
						array( 'act'       , 'market'             ),
						array( 'code'      , 'plugin'             ),
						array( 'do'        , 'run'                ),
						array( 'link'      , $this->plugin['link'])
						);
		
		foreach($a as $array)
		{
			$form[] = $array;
		}
		$html .= $this->ipsclass->adskin->start_form( $form, $n, $js );
		
		return $html;
	}
	
	function run() { return; }
	
	function _load(&$plugin)
	{
		$this->plugin = &$plugin;
		//$this->base_url = $this->ipsclass->market_class->base_url.'plugin='.$link.'&amp;';
		
		if($plugin['link'])
		{
			$this->_load_cache();
		}
	}

	function _load_cache()
	{
		if(!is_array($this->cache_array) || count($this->cache_array) == 0 )
		{
			return -1;
		}
		
		$need_to_pull = array();
		foreach(array_keys($this->cache_array) as $key)
		{
			if(!isset($this->ipsclass->cache[$key]))
			{
				$need_to_pull[] = $key;
			}
		}
		
		if(count($need_to_pull) > 0)
		{
			$this->ipsclass->init_load_cache($need_to_pull);
		}
		
		return count($need_to_pull);
	}

	function _output($output)
	{
		$this->ipsclass->output = $output;
		$this->ipsclass->nav = array();
	}
}
?>